<%@include file="template/configuration.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Profile of ${userFullDetails.firstname} ${userFullDetails.insertion} ${userFullDetails.lastname}</title>
        ${stylesheet}
        ${jquery}
        ${jsdropdown}
    </head>
    <body>
        <div class="container">
            <%@include file="template/header.jsp" %>
            <div class="content">
                <h1>${userFullDetails.firstname} ${userFullDetails.insertion} ${userFullDetails.lastname}   <c:choose><c:when test="${userD.member_id==sessionScope.user.member_id&&userFullDetails.hidden}">(private)</c:when></c:choose></h1>
                        <div class="clear margin-bottom-10"></div>
                        <div>                                    
                            <div id="tabs" class="full-block">

                                <ul>
                                    <li><a href="#tabs-1">Profile</a></li>                
                                    <li><a href="#tabs-2">Notes</a></li>  
                            <c:if test="${userD.member_id==sessionScope.user.member_id}">                                                                        
                                <li><a href="${url}EditProfile?id=${userFullDetails.id}">Edit</a></li>
                            </c:if>                            
                        </ul>

                        <div id="tabs-1">
                            <c:choose><c:when test="${userD.member_id!=sessionScope.user.member_id&&userFullDetails.hidden && isStudent}"><center><img src="${url}images/locked.png"/></br>This profile is hidden from public.</center></c:when>
                                    <c:otherwise>
                                    <table>
                                        <tr>
                                            <c:choose><c:when test="${userFullDetails.profileurl!=null}">
                                                    <td width="155"></h6><img src="${url}${userFullDetails.profileurl}" width="150" height="250"/> <c:if test="${userD.member_id==sessionScope.user.member_id}"><h6><a href="jsp/edit_profile_picture.jsp">edit picture</a></c:if></td></c:when>
                                                <c:otherwise><td width="155"></h6><img src="${url}images/anonymous.png" width="150" height="250"/><c:if test="${userD.member_id==sessionScope.user.member_id}"><h6><a href="jsp/edit_profile_picture.jsp">edit picture</a></td></c:if></c:otherwise>
                                                </c:choose>
                                            <td>
                                                <table>                       
                                                    <tr><td>
                                                            <label>Joined on:</label> <div class="information-text">${userD.date}</div>
                                                        </td></tr>                                
                                                    <tr><td>
                                                            <label>Gender:</label> <div class="information-text">${userFullDetails.gender}</div>
                                                        </td></tr>                                                                    
                                                    <tr><td>
                                                            <label>Interests:</label> <div class="information-text">${userFullDetails.interests}</div>
                                                        </td></tr>                                
                                                    <tr><td>
                                                            <label><c:choose><c:when test="${isStudent}">Courses attending:</c:when><c:otherwise>Courses given:</c:otherwise></c:choose></label> <div class="information-text"><c:forEach items="${courses}" var="courses">${courses.name}; </c:forEach></div>
                                                            </td></tr>  
                                                        <tr><td>
                                                                <label>Role:</label> <div class="information-text"><c:choose><c:when test="${isStudent}">Student</c:when><c:otherwise>${userFullDetails.role.name}</c:otherwise></c:choose></div>

                                                                </td></tr>
                                                        </table>

                                                    </td>
                                                    <td style="text-align: center; vertical-align: top; padding-top: 15px;">
                                                        <a href="${url}ComposePrivateMessage?action=compose&receiver=${userD.member_id}">Send PM<img src="${url}images/mail.png" /></a>
                                                    </td>
                                                </tr>                        
                                            </table> 
                                </c:otherwise>
                            </c:choose>
                        </div>
                        <div id="tabs-2">
                            <c:choose>
                                <c:when test="${user.member_id ==userD.member_id}">

                                    <h4 class="search"><img src="${url}images/noteiconbg.jpg"/> My notes</h4>
                                    <table class="overview">
                                        <tr>
                                            <th>Made in lesson</th>
                                            <th>Course</th>
                                            <th>Date added</th>
                                            <th>View</th>
                                        </tr>
                                        <c:forEach items="${note}" var="note">
                                            <c:set var="i" value="${i + 1}"/>
                                            <tr class="<c:choose><c:when test="${i % 2 == 0}">even</c:when><c:otherwise>odd</c:otherwise></c:choose>">
                                                <td>${note.lesson.name}</td>
                                                <td>

                                                    <c:forEach items="${courses}" var="course">
                                                        <c:if test="${course.id==note.lesson.course.id}">
                                                            ${course.name}
                                                        </c:if>
                                                    </c:forEach>

                                                </td>
                                                <td>${note.date}</td><td><a href="LectureController?id=${note.lesson.id}#NOTE"><img src="${url}images/note.png"/></a></td>
                                            </tr>
                                        </c:forEach>
                                    </table>
                                    <c:choose>
                                        <c:when test="${fn:length(note)==0}">
                                            You have not made any notes.
                                        </c:when>
                                    </c:choose>

                                </c:when><c:otherwise></c:otherwise>
                            </c:choose>        
                        </div>
                        <div id="tabs-3">                            
                        </div>
                    </div>                
                </div>
            </div>
            <%@include file="template/footer.jsp" %>
        </div>
    </body>
</html>        
